
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Router 构造配置 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="router-instance.html" />
    
    
    <link rel="prev" href="route-object.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../installation.html">
            
                <a href="../installation.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    基础
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../essentials/getting-started.html">
            
                <a href="../essentials/getting-started.html">
            
                    
                    开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../essentials/dynamic-matching.html">
            
                <a href="../essentials/dynamic-matching.html">
            
                    
                    动态路由匹配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../essentials/nested-routes.html">
            
                <a href="../essentials/nested-routes.html">
            
                    
                    嵌套路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../essentials/navigation.html">
            
                <a href="../essentials/navigation.html">
            
                    
                    编程式导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../essentials/named-routes.html">
            
                <a href="../essentials/named-routes.html">
            
                    
                    命名路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../essentials/named-views.html">
            
                <a href="../essentials/named-views.html">
            
                    
                    命名视图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../essentials/redirect-and-alias.html">
            
                <a href="../essentials/redirect-and-alias.html">
            
                    
                    重定向 和 别名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../essentials/history-mode.html">
            
                <a href="../essentials/history-mode.html">
            
                    
                    HTML5 History 模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    进阶
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../advanced/navigation-guards.html">
            
                <a href="../advanced/navigation-guards.html">
            
                    
                    导航钩子
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../advanced/meta.html">
            
                <a href="../advanced/meta.html">
            
                    
                    路由元信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../advanced/transitions.html">
            
                <a href="../advanced/transitions.html">
            
                    
                    过渡动效
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../advanced/data-fetching.html">
            
                <a href="../advanced/data-fetching.html">
            
                    
                    数据获取
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../advanced/scroll-behavior.html">
            
                <a href="../advanced/scroll-behavior.html">
            
                    
                    滚动行为
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../advanced/lazy-loading.html">
            
                <a href="../advanced/lazy-loading.html">
            
                    
                    懒加载
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    API 文档
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="router-link.html">
            
                <a href="router-link.html">
            
                    
                    router-link
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="router-view.html">
            
                <a href="router-view.html">
            
                    
                    router-view
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="route-object.html">
            
                <a href="route-object.html">
            
                    
                    路由信息对象
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.4" data-path="options.html">
            
                <a href="options.html">
            
                    
                    Router 构造配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="router-instance.html">
            
                <a href="router-instance.html">
            
                    
                    Router 实例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="component-injections.html">
            
                <a href="component-injections.html">
            
                    
                    对组件注入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Router 构造配置</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="router-&#x6784;&#x9020;&#x914D;&#x7F6E;">Router &#x6784;&#x9020;&#x914D;&#x7F6E;</h1>
<h3 id="routes">routes</h3>
<ul>
<li><p>&#x7C7B;&#x578B;: <code>Array&lt;RouteConfig&gt;</code></p>
<p><code>RouteConfig</code> &#x7684;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#xFF1A;</p>
<pre><code class="lang-js">declare type RouteConfig = {
  path: string;
  component?: Component;
  name?: string; <span class="hljs-comment">// for named routes (&#x547D;&#x540D;&#x8DEF;&#x7531;)</span>
  components?: { [name: string]: Component }; <span class="hljs-comment">// for named views (&#x547D;&#x540D;&#x89C6;&#x56FE;&#x7EC4;&#x4EF6;)</span>
  redirect?: string | Location | <span class="hljs-built_in">Function</span>;
  alias?: string | <span class="hljs-built_in">Array</span>&lt;string&gt;;
  children?: <span class="hljs-built_in">Array</span>&lt;RouteConfig&gt;; <span class="hljs-comment">// for nested routes</span>
  beforeEnter?: (to: Route, <span class="hljs-keyword">from</span>: Route, next: <span class="hljs-built_in">Function</span>) =&gt; <span class="hljs-keyword">void</span>;
  meta?: any;
}
</code></pre>
</li>
</ul>
<h3 id="mode">mode</h3>
<ul>
<li><p>&#x7C7B;&#x578B;: <code>string</code></p>
</li>
<li><p>&#x9ED8;&#x8BA4;&#x503C;: <code>&quot;hash&quot; (&#x6D4F;&#x89C8;&#x5668;&#x73AF;&#x5883;) | &quot;abstract&quot; (Node.js &#x73AF;&#x5883;)</code></p>
</li>
<li><p>&#x53EF;&#x9009;&#x503C;: <code>&quot;hash&quot; | &quot;history&quot; | &quot;abstract&quot;</code></p>
<p>&#x914D;&#x7F6E;&#x8DEF;&#x7531;&#x6A21;&#x5F0F;:</p>
<ul>
<li><p><code>hash</code>: &#x4F7F;&#x7528; URL hash &#x503C;&#x6765;&#x4F5C;&#x8DEF;&#x7531;&#x3002;&#x652F;&#x6301;&#x6240;&#x6709;&#x6D4F;&#x89C8;&#x5668;&#xFF0C;&#x5305;&#x62EC;&#x4E0D;&#x652F;&#x6301; HTML5 History Api &#x7684;&#x6D4F;&#x89C8;&#x5668;&#x3002;</p>
</li>
<li><p><code>history</code>: &#x4F9D;&#x8D56; HTML5 History API &#x548C;&#x670D;&#x52A1;&#x5668;&#x914D;&#x7F6E;&#x3002;&#x67E5;&#x770B; <a href="../essentials/history-mode.html">HTML5 History &#x6A21;&#x5F0F;</a>.</p>
</li>
<li><p><code>abstract</code>: &#x652F;&#x6301;&#x6240;&#x6709; JavaScript &#x8FD0;&#x884C;&#x73AF;&#x5883;&#xFF0C;&#x5982; Node.js &#x670D;&#x52A1;&#x5668;&#x7AEF;&#x3002;<strong>&#x5982;&#x679C;&#x53D1;&#x73B0;&#x6CA1;&#x6709;&#x6D4F;&#x89C8;&#x5668;&#x7684; API&#xFF0C;&#x8DEF;&#x7531;&#x4F1A;&#x81EA;&#x52A8;&#x5F3A;&#x5236;&#x8FDB;&#x5165;&#x8FD9;&#x4E2A;&#x6A21;&#x5F0F;&#x3002;</strong></p>
</li>
</ul>
</li>
</ul>
<h3 id="base">base</h3>
<ul>
<li><p>&#x7C7B;&#x578B;: <code>string</code></p>
</li>
<li><p>&#x9ED8;&#x8BA4;&#x503C;: <code>&quot;/&quot;</code></p>
<p>&#x5E94;&#x7528;&#x7684;&#x57FA;&#x8DEF;&#x5F84;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x5982;&#x679C;&#x6574;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x670D;&#x52A1;&#x5728; <code>/app/</code> &#x4E0B;&#xFF0C;&#x7136;&#x540E; <code>base</code> &#x5C31;&#x5E94;&#x8BE5;&#x8BBE;&#x4E3A; <code>&quot;/app/&quot;</code>&#x3002;</p>
</li>
</ul>
<h3 id="linkactiveclass">linkActiveClass</h3>
<ul>
<li><p>&#x7C7B;&#x578B;: <code>string</code></p>
</li>
<li><p>&#x9ED8;&#x8BA4;&#x503C;: <code>&quot;router-link-active&quot;</code></p>
<p>&#x5168;&#x5C40;&#x914D;&#x7F6E; <code>&lt;router-link&gt;</code> &#x7684;&#x9ED8;&#x8BA4;&#x300E;&#x6FC0;&#x6D3B; class &#x7C7B;&#x540D;&#x300F;&#x3002;&#x53C2;&#x8003; <a href="router-link.html">router-link</a>.</p>
</li>
</ul>
<h3 id="scrollbehavior">scrollBehavior</h3>
<ul>
<li><p>&#x7C7B;&#x578B;: <code>Function</code></p>
<p>&#x7B7E;&#x540D;:</p>
<pre><code>(
  to: Route,
  from: Route,
  savedPosition?: { x: number, y: number }
) =&gt; { x: number, y: number } | { selector: string } | ?{}
</code></pre><p>&#x66F4;&#x591A;&#x8BE6;&#x60C5;&#x53C2;&#x8003; <a href="../advanced/scroll-behavior.html">&#x6EDA;&#x52A8;&#x884C;&#x4E3A;</a>.</p>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="route-object.html" class="navigation navigation-prev " aria-label="Previous page: 路由信息对象">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="router-instance.html" class="navigation navigation-next " aria-label="Next page: Router 实例">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Router 构造配置","level":"1.5.4","depth":2,"next":{"title":"Router 实例","level":"1.5.5","depth":2,"path":"api/router-instance.md","ref":"api/router-instance.md","articles":[]},"previous":{"title":"路由信息对象","level":"1.5.3","depth":2,"path":"api/route-object.md","ref":"api/route-object.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"api/options.md","mtime":"2017-03-04T12:16:27.890Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-06T16:00:44.406Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

